package vn.student.mylib;

import vn.student.R;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.DatePicker;

public class DateDialog implements android.content.DialogInterface.OnClickListener {
	public static void viewDialog(String title,Context ctx,String[] dueDate, android.content.DialogInterface.OnClickListener onOkClickListener){
		 
		LayoutInflater li = LayoutInflater.from(ctx); 
		View view = li.inflate(R.layout.date_dialog, null); 
		   
		AlertDialog.Builder builder = new AlertDialog.Builder(ctx); 
		builder.setTitle(title); 
		builder.setView(view); 
		  
		if(dueDate!=null&&dueDate.length==3){
			DatePicker tmp = ((DatePicker) view.findViewById(R.id.datePicker));
			tmp.updateDate(Integer.valueOf(dueDate[0]), Integer.valueOf(dueDate[1])-1, Integer.valueOf(dueDate[2]));
		}
		
		builder.setPositiveButton("OK", onOkClickListener); 
		builder.setNegativeButton("Cancel", new DateDateDialog()); 
		   
		//get the dialog 
		AlertDialog ad = builder.create(); 
		
		ad.show(); 
	}
	@Override
	public void onClick(DialogInterface dialog, int which) {
		// TODO Auto-generated method stub
		
	}
}